<div>
    <ol class="breadcrumb" >
        <li> <i class="fa fa-anchor"></i>
            &nbsp;电桩管理
        </li>
        <li>电桩列表</li>
        <!--<li style="float:right"><a href={:U("Evcharger/add")} class="localRgihtBt"><b> 添加电桩</b></a></li>-->
    </ol>
    <div class="panel">
        <div class="panel-heading" >
            <i class="fa fa-list"></i>
            &nbsp;&nbsp;电桩信息表
        </div>
        <form class="search-form" action={:U("Evcharger/index")} method="get">
            <div class="panel-body search-panel-body">
                <div class="col-xs-4" style=" width:500px;">
                    <div class="input-group">
                        <span class="input-group-addon" style="width:80px;">所在地</span>
                        <select id="location-f" name="location_f_1" class="form-control" style="width:139px;">
                            <option value="0">--</option>
                            <volist name="china" id="vo">
                                <option value="{$vo.code}">{$vo.name}</option>
                            </volist>
                        </select>

                        <select id="location-s" name="location_s_1" class="form-control" style="width:125px;border-left:0">
                            <option value="0">--</option>
                            <volist name="china" id="vo">
                                <volist name="vo['area']" id="vovo">
                                    <option value="{$vovo.code}" class="{$vo.code}" >{$vovo.name}</option>
                                </volist>
                            </volist>
                        </select>

                        <select id="location-t" name="location_t_1" class="form-control required" style="width:125px;border-left:0">
                            <option value="0">--</option>
                            <volist name="china" id="vo">
                                <volist name="vo['area']" id="vovo">
                                    <volist name="vovo['area']" id="vovovo">
                                        <option value="{$vovovo.code}" class="{$vovo.code}" >{$vovovo.name}</option>
                                    </volist>
                                </volist>
                            </volist>
                        </select>
                    </div>
                </div>
                <div class="col-xs-5 search-col">
                    <div class="input-group">
                        <span class="input-group-addon">运营二维码</span>
                        <input type="text" name="evc_number" class="form-control" maxlength="12" value="{$_GET['evc_number']}" placeholder="运营二维码">
                        <span class="input-group-addon">设备地址</span>
                        <input type="text" name="key_link" class="form-control" maxlength="16" value="{$_GET['key_link']}" placeholder="设备地址">
                    </div>
                </div>
                <div class="col-xs-1 search-col">
                    <button  type="submit" class="btn btn-warning">
                        <i class="fa fa-search"></i>
                        &nbsp;搜索
                    </button>
                </div>
            </div>
        </form>
        <table  class="table table-bordered table-striped table-mcit" >
            <thead>
            <tr>
                <th >
                    <button class='btn btn-block btn-mcit' type='button' name='' value=''>ID</button>
                </th>
                <th>
                    <button class='btn btn-block btn-mcit' type='button' name='' value=''>站点名称</button>
                </th>
                <th>
                    <button class='btn btn-block btn-mcit' type='button' name='' value=''>所在区域</button>
                </th>
                <th>
                    <button class='btn btn-block btn-mcit' type='button' name='' value=''>运营二维码</button>
                </th>
                <th>
                    <button class='btn btn-block btn-mcit' type='button' name='' value=''>设备地址</button>
                </th>
                <th>
                    <button class='btn btn-block btn-mcit' type='button' name='' value=''>类型</button>
                </th>
                <th>
                    <button class='btn btn-block btn-mcit' type='button' name='' value=''>属性</button>
                </th>
                <th>
                    <button class='btn btn-block btn-mcit' type='button' name='' value=''>安装时间</button>
                </th>
                <th>
                    <button class='btn btn-block btn-mcit' type='button' name='' value=''>操作</button>
                </th>
            </tr>
            </thead>
            <tbody id="DataTableContent">
            <empty name="ev_char">
                <td colspan="99" style="text-align:center" class="danger"> <strong><i class="fa fa-meh-o"></i>
                    &nbsp;&nbsp;当前条件下没有数据</strong>
                </td>
                <else />
                <volist name="ev_char" id="data">
                    <tr align="center">
                        <td>{$data.id}</td>
                        <td ><span title="{$data.plant_name}">{$data.plant_name_text}</span></td>
                        <td><span title="{$data.plantinfo.address}">{$data.region_text}</span></td>
                        <td>
                            <if condition="$data.evc_number eq ''">
                                <a class="btn  btn-xs create"  data-code="{$data.key_link}"  data-id="{$data.id}" data-info="确定生成【运营二维码】吗？">
                                    <img src="__PUBLIC__/img/create.png" alt="启动"/>
                                </a>
                            <else />
                                {$data.evc_number}
                            </if>
                        </td>
                        <td>{$data.key_link}</td>
                        <td><if condition="$data.evc_type eq 1">直流<elseif condition="$data.evc_type eq 3" />混合<else />交流</if></td>
                        <td><if condition="$data.evc_quantity eq 1">单枪<else />双枪</if></td>
                        <td>{$data.sys_creat_time}</td>
                        <td>
                            <a class="btn btn-success btn-sm" href="__URL__/detail/id/{$data.id}">
                                <i class="fa fa-eye"></i>
                                &nbsp;查看
                            </a>
                            <a class="btn btn-warning btn-sm" href="__URL__/update/id/{$data.id}">
                                <i class="fa fa-edit"></i>
                                &nbsp;修改
                            </a>
                            <a class="btn btn-sm btn-danger deleteBtn" href="#confirmDelete" data-target="#confirmDelete" data-toggle="modal" data-id='{$data.id}'>
                                <i class="fa fa-trash-o"></i>
                                &nbsp;删除</a>
                        </td>
                    </tr>
                </volist>
            </empty>
            <tr>
                <td colspan="99" style="text-align:center">
                    <ul class="pagination">{$pageView}</ul>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>
<!-- 删除分类 -->
<div id="confirmDelete" class="modal  fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 id="myModalLabel">是否确认删除？</h4>
            </div>
            <div class="modal-body" style="color: #D2322D">
                注意！删除后将不可恢复。
            </div>
            <div class="modal-footer">
                <a class="btn" data-dismiss="modal" aria-hidden="true" id="modelClose">关闭</a>
                <a class="btn btn-primary" id="confirmDeleteBtn">确定</a>
            </div>
        </div></div>
    <div class="hide" id="cache">1</div>
</div>
<import file="js.jquery#chained" />
<script type="text/javascript">
    $(document).ready(function () {
        $("#location-s").chained("#location-f");
        $("#location-t").chained("#location-s");

        //生成运营二维码
        $(document).on("click",'.create',function(){
            var aobj     = $(this).parent();
            var aid      = $(this).attr("data-id");//ID
            var ainfo    = $(this).attr("data-info");
            var key_link = $(this).attr("data-code");//key_link
            //alert(key_link);
            alertify.confirm(ainfo, function (i) {
                if (i) {
                    $.ajax({
                        type: "POST",
                        url:  '{:U("Evcharger/createEvcNumber")}',
                        data: {id:aid,key_link:key_link},
                        dataType: "json",
                        success: function(data){
                            if(data.state==100){
                                alertify.success(data.msg);
                                location.reload();
                            }else{
                                alertify.error(data.msg);
                            }
                        }
                    });
                } else {
                    alertify.error("取消操作！");
                }
            }, "mcit_default");
        });

        $(".deleteBtn").click(function (){
            var id = $(this).attr("data-id");
            $("#cache").val(id);
        });

        $("#confirmDeleteBtn").click(function (){
            var id = $("#cache").val();
//            alert(id);
            $.ajax({
                type:"get",
                url:'__URL__/delChar',
                data:'id='+id,
                success:function(data){
                    if(data == 1){
                        alertify.success("删除成功！");
                    }else{
                        alertify.error("删除失败，请重新提交！");
                    }
                    location.reload();
                }
            });
        });

    });
</script>